<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<meta name="layout" content="main" />
        <link rel="stylesheet" href="${createLinkTo(dir:'css',file:'auction.css')}" />
		<title>${auction?.title}</title>
	</head>
	<body>

		<div class="nav">
            <g:ifAllGranted role="ROLE_ADMIN">
                <span class="menuButton"><g:link class="list" action="list">Lista aukcji</g:link></span>
                <span class="menuButton"><g:link class="create" action="create">Nowa aukcja</g:link></span>
            </g:ifAllGranted>
		</div>

        <g:ifAllGranted role="ROLE_ADMIN">
            <div class="buttons">
                <g:form>
                    <input type="hidden" name="id" value="${auction.id}" />
                    <span class="button"><g:actionSubmit class="edit" value="Edytuj" action="edit"/></span>
                    <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Usuń" action="delete"/></span>
                </g:form>
            </div>
        </g:ifAllGranted>

		<div class="body">
			<h1>${auction?.title} (Aukcja numer: ${auction?.id})</h1>
            <h3>${auction?.shortDescription}</h3>
			<g:if test="${flash.message}">
			<div class="message">${flash.message}</div>
			</g:if>
			<div id="show">
                <p><jep:finish date="${auction.finish}" /></p>
                <div id="head">
                    <div id="cena">
                        <p>Aktualna cena:</p>
                        <p id="price">${auction.getPrice()?.encodeAsHTML()}</p>
                    </div>
                    <div id="licytacja">
                        <g:if test="${auction.finish.compareTo(new Date()) > 0}">
                            <jep:offerForm auction="${auction}"/>
                        </g:if>
                    </div>
                </div>
                <div id="opis">
                    ${auction.description}
                </div>
			</div>
            <div id="oferty">
                <g:if test="${auction.offers.size() > 0}">
                    <h4>Oferty:</h4>
                    <table>
                    <tbody>
                        <g:each in="${auction.offers}">
                            <tr>
                                <td><jep:date date="${it?.dateCreated}" /></td>
                                <td>${it?.person?.encodeAsHTML()}</td>
                                <td>${it?.price?.encodeAsHTML()}</td>
                            </tr>
                        </g:each>
                    </tbody>
                    </table>
                </g:if>
            </div>
		</div>
	</body>
</html>

